﻿#region License

// Another free, open solution by folks who get it.
// Copyright © 2011 Business in Unison, Inc.
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#endregion

namespace Patterns.IO
{
	/// <summary>
	/// 	Provides quick access to Windows-compliant file size measurements.
	/// </summary>
	public static class FileSize
	{
		private const long _kb = 1024;
		private const long _mb = _kb*_kb;
		private const long _gb = _mb*_kb;
		private const long _tb = _gb*_kb;
		private const long _pb = _tb*_kb;

		/// <summary>
		/// 	Gets the specified number of kilobytes.
		/// </summary>
		/// <param name = "kilobytes">The kilobytes.</param>
		/// <returns></returns>
		public static long FromKilobytes(int kilobytes)
		{
			return _kb*kilobytes;
		}

		/// <summary>
		/// 	Gets the specified number of megabytes.
		/// </summary>
		/// <param name = "megabytes">The megabytes.</param>
		/// <returns></returns>
		public static long FromMegabytes(int megabytes)
		{
			return _mb*megabytes;
		}

		/// <summary>
		/// 	Gets the specified number of gigabytes.
		/// </summary>
		/// <param name = "gigabytes">The gigabytes.</param>
		/// <returns></returns>
		public static long FromGigabytes(int gigabytes)
		{
			return _gb*gigabytes;
		}

		/// <summary>
		/// 	Gets the specified number of terabytes.
		/// </summary>
		/// <param name = "terabytes">The terabytes.</param>
		/// <returns></returns>
		public static long FromTerabytes(int terabytes)
		{
			return _tb*terabytes;
		}

		/// <summary>
		/// 	Gets the specified number of petabytes.
		/// </summary>
		/// <param name = "petabytes">The petabytes.</param>
		/// <returns></returns>
		public static long FromPetabytes(int petabytes)
		{
			return _pb*petabytes;
		}
	}
}